#include<bits/stdc++.h>
using namespace std;
int T,m,n,L,V,d[100005],v[100005],a[100005],p[100005];
double testx(int p,int s,int a,int v){
    return pow(v*v+2*a*s,0.5);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        sort(p+1,p+m+1);
        double px=p[m],vs;
        int ans=0;
        for(int i=1;i<=n;i++){
            if(testx(px,px-d[i],a[i],v[i])>V&&d[i]<=px)ans++;
        }
        cout<<ans<<" ";
        if(ans==0)cout<<m;
        else cout<<m-1;
        cout<<'\n';
    }
    return 0;
}
